using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpaceTimePatternMiningTools._SpaceTimePatternAnalysis
{
    /// <summary>
    /// <para>Local Outlier Analysis</para>
    /// <para>Identifies statistically significant clusters and outliers in the context of both space and time.  This tool is a space-time implementation of the Anselin Local Moran's I statistic.</para>
    /// <para>在空间和时间上下文中识别具有统计显著性的聚类和异常值。 该工具是 Anselin Local Moran's I 统计量的时空实现。</para>
    /// </summary>    
    [DisplayName("Local Outlier Analysis")]
    public class LocalOutlierAnalysis : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public LocalOutlierAnalysis()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_cube">
        /// <para>Input Space Time Cube</para>
        /// <para>The netCDF cube to be analyzed. This file must have an (.nc) extension and must have been created using either the Create Space Time Cube By Aggregating Points or Create Space Time Cube From Defined Features tool.</para>
        /// <para>要分析的 netCDF 多维数据集。此文件必须具有 （.nc） 扩展名，并且必须已使用“通过聚合点创建时空立方体”或“根据定义要素创建时空立方体”工具创建。</para>
        /// </param>
        /// <param name="_analysis_variable">
        /// <para>Analysis Variable</para>
        /// <para>The numeric variable in the netCDF file you want to analyze.</para>
        /// <para>要分析的 netCDF 文件中的数值变量。</para>
        /// </param>
        /// <param name="_output_features">
        /// <para>Output Features</para>
        /// <para>The output feature class containing locations that were considered statistically significant clusters or outliers.</para>
        /// <para>输出要素类，包含被视为具有统计显著性聚类或异常值的位置。</para>
        /// </param>
        public LocalOutlierAnalysis(object _in_cube, object _analysis_variable, object _output_features)
        {
            this._in_cube = _in_cube;
            this._analysis_variable = _analysis_variable;
            this._output_features = _output_features;
        }
        public override string ToolboxName => "Space Time Pattern Mining Tools";

        public override string ToolName => "Local Outlier Analysis";

        public override string CallName => "stpm.LocalOutlierAnalysis";

        public override List<string> AcceptEnvironments => ["geographicTransformations", "outputCoordinateSystem", "parallelProcessingFactor", "randomGenerator", "scratchWorkspace", "workspace"];

        public override object[] ParameterInfo => [_in_cube, _analysis_variable, _output_features, _neighborhood_distance, _neighborhood_time_step, _number_of_permutations, _polygon_mask, _conceptualization_of_spatial_relationships.GetGPValue(), _number_of_neighbors, _define_global_window.GetGPValue()];

        /// <summary>
        /// <para>Input Space Time Cube</para>
        /// <para>The netCDF cube to be analyzed. This file must have an (.nc) extension and must have been created using either the Create Space Time Cube By Aggregating Points or Create Space Time Cube From Defined Features tool.</para>
        /// <para>要分析的 netCDF 多维数据集。此文件必须具有 （.nc） 扩展名，并且必须已使用“通过聚合点创建时空立方体”或“根据定义要素创建时空立方体”工具创建。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Space Time Cube")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_cube { get; set; }


        /// <summary>
        /// <para>Analysis Variable</para>
        /// <para>The numeric variable in the netCDF file you want to analyze.</para>
        /// <para>要分析的 netCDF 文件中的数值变量。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Analysis Variable")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _analysis_variable { get; set; }


        /// <summary>
        /// <para>Output Features</para>
        /// <para>The output feature class containing locations that were considered statistically significant clusters or outliers.</para>
        /// <para>输出要素类，包含被视为具有统计显著性聚类或异常值的位置。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _output_features { get; set; }


        /// <summary>
        /// <para>Neighborhood Distance</para>
        /// <para>The spatial extent of the analysis neighborhood. This value determines which features are analyzed together in order to assess local space-time clustering.</para>
        /// <para>分析邻域的空间范围。该值确定将哪些特征一起分析，以便评估局部时空聚类。</para>
        /// <para>单位： Feet | Meters | Kilometers | Miles </para>
        /// </summary>
        [DisplayName("Neighborhood Distance")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public string? _neighborhood_distance { get; set; } = null;


        /// <summary>
        /// <para>Neighborhood Time Step</para>
        /// <para>The number of time-step intervals to include in the analysis neighborhood. This value determines which features are analyzed together in order to assess local space-time clustering.</para>
        /// <para>要包含在分析邻域中的时间步长间隔数。该值确定将哪些特征一起分析，以便评估局部时空聚类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Neighborhood Time Step")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _neighborhood_time_step { get; set; } = 1;


        /// <summary>
        /// <para>Number of Permutations</para>
        /// <para><xdoc>
        ///   <para>The number of random permutations for the calculation of pseudo p-values. The default number of permutations is 499. If you choose 0 permutations, the standard p-value is calculated.</para>
        ///   <bulletList>
        ///     <bullet_item>0—Permutations are not used and a standard p-value is calculated.</bullet_item><para/>
        ///     <bullet_item>99—With 99 permutations, the smallest possible pseudo p-value is 0.01 and all other pseudo p-values will be even multiples of this value.</bullet_item><para/>
        ///     <bullet_item>199—With 199 permutations, the smallest possible pseudo p-value is 0.005 and all other pseudo p-values will be even multiples of this value.</bullet_item><para/>
        ///     <bullet_item>499—With 499 permutations, the smallest possible pseudo p-value is 0.002 and all other pseudo p-values will be even multiples of this value.</bullet_item><para/>
        ///     <bullet_item>999—With 999 permutations, the smallest possible pseudo p-value is 0.001 and all other pseudo p-values will be even multiples of this value.</bullet_item><para/>
        ///     <bullet_item>9999—With 9999 permutations, the smallest possible pseudo p-value is 0.0001 and all other pseudo p-values will be even multiples of this value.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于计算伪 p 值的随机排列数。默认排列数为 499。如果选择 0 种排列，则计算标准 p 值。</para>
        ///   <bulletList>
        ///     <bullet_item>0 - 不使用排列，并计算标准 p 值。</bullet_item><para/>
        ///     <bullet_item>99 - 对于 99 个排列，可能的最小伪 p 值为 0.01，所有其他伪 p 值将是该值的偶数倍。</bullet_item><para/>
        ///     <bullet_item>199 - 对于 199 个排列，最小可能的伪 p 值为 0.005，所有其他伪 p 值将是该值的偶数倍。</bullet_item><para/>
        ///     <bullet_item>499 - 对于 499 个排列，可能的最小伪 p 值为 0.002，所有其他伪 p 值将是该值的偶数倍。</bullet_item><para/>
        ///     <bullet_item>999 - 对于 999 排列，可能的最小伪 p 值为 0.001，所有其他伪 p 值将是该值的偶数倍。</bullet_item><para/>
        ///     <bullet_item>9999 - 对于 9999 排列，可能的最小伪 p 值为 0.0001，所有其他伪 p 值将是此值的偶数倍。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Permutations")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_permutations { get; set; } = 499;


        /// <summary>
        /// <para>Polygon Analysis Mask</para>
        /// <para><xdoc>
        ///   <para>A polygon feature layer with one or more polygons defining the analysis study area. You would use a polygon analysis mask to exclude a large lake from the analysis, for example. Bins defined in the Input Space Time Cube that fall outside of the mask will not be included in the analysis.</para>
        ///   <para>This parameter is only available for grid cubes.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>具有一个或多个面的面要素图层，用于定义分析研究区域。例如，您可以使用面分析掩码从分析中排除一个大湖。在输入时空立方体中定义的位于掩码之外的图格将不包括在分析中。</para>
        ///   <para>此参数仅适用于网格多维数据集。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Polygon Analysis Mask")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _polygon_mask { get; set; } = null;


        /// <summary>
        /// <para>Conceptualization of Spatial Relationships</para>
        /// <para><xdoc>
        ///   <para>Specifies how spatial relationships among features are defined.</para>
        ///   <bulletList>
        ///     <bullet_item>Fixed distance—Each bin is analyzed within the context of neighboring bins. Neighboring bins inside the specified critical distance (Neighborhood Distance) receive a weight of one and exert influence on computations for the target bin. Neighboring bins outside the critical distance receive a weight of zero and have no influence on a target bin's computations.</bullet_item><para/>
        ///     <bullet_item>K nearest neighbors—The closest k bins are included in the analysis for the target bin; k is a specified numeric parameter.</bullet_item><para/>
        ///     <bullet_item>Contiguity edges only—Only neighboring bins that share an edge will influence computations for the target polygon bin.</bullet_item><para/>
        ///     <bullet_item>Contiguity edges corners—Bins that share an edge or share a node will influence computations for the target polygon bin.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何定义要素之间的空间关系。</para>
        ///   <bulletList>
        ///     <bullet_item>固定距离 - 在相邻图格的上下文中分析每个图格。指定临界距离（邻域距离）内的相邻条柱的权重为 1，并对目标条柱的计算产生影响。临界距离之外的相邻箱的权重为零，对目标箱的计算没有影响。</bullet_item><para/>
        ///     <bullet_item>K 最近邻—目标条柱的分析中包括最近的 k 条柱;k 是指定的数值参数。</bullet_item><para/>
        ///     <bullet_item>仅邻接边 - 只有共享边的相邻条柱才会影响目标面条柱的计算。</bullet_item><para/>
        ///     <bullet_item>连续性边角 - 共享边或共享节点的图格将影响目标面图格的计算。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Conceptualization of Spatial Relationships")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _conceptualization_of_spatial_relationships_value _conceptualization_of_spatial_relationships { get; set; } = _conceptualization_of_spatial_relationships_value._FIXED_DISTANCE;

        public enum _conceptualization_of_spatial_relationships_value
        {
            /// <summary>
            /// <para>Fixed distance</para>
            /// <para>Fixed distance—Each bin is analyzed within the context of neighboring bins. Neighboring bins inside the specified critical distance (Neighborhood Distance) receive a weight of one and exert influence on computations for the target bin. Neighboring bins outside the critical distance receive a weight of zero and have no influence on a target bin's computations.</para>
            /// <para>固定距离 - 在相邻图格的上下文中分析每个图格。指定临界距离（邻域距离）内的相邻条柱的权重为 1，并对目标条柱的计算产生影响。临界距离之外的相邻箱的权重为零，对目标箱的计算没有影响。</para>
            /// </summary>
            [Description("Fixed distance")]
            [GPEnumValue("FIXED_DISTANCE")]
            _FIXED_DISTANCE,

            /// <summary>
            /// <para>K nearest neighbors</para>
            /// <para>K nearest neighbors—The closest k bins are included in the analysis for the target bin; k is a specified numeric parameter.</para>
            /// <para>K 最近邻—目标条柱的分析中包括最近的 k 条柱;k 是指定的数值参数。</para>
            /// </summary>
            [Description("K nearest neighbors")]
            [GPEnumValue("K_NEAREST_NEIGHBORS")]
            _K_NEAREST_NEIGHBORS,

            /// <summary>
            /// <para>Contiguity edges only</para>
            /// <para>Contiguity edges only—Only neighboring bins that share an edge will influence computations for the target polygon bin.</para>
            /// <para>仅邻接边 - 只有共享边的相邻条柱才会影响目标面条柱的计算。</para>
            /// </summary>
            [Description("Contiguity edges only")]
            [GPEnumValue("CONTIGUITY_EDGES_ONLY")]
            _CONTIGUITY_EDGES_ONLY,

            /// <summary>
            /// <para>Contiguity edges corners</para>
            /// <para>Contiguity edges corners—Bins that share an edge or share a node will influence computations for the target polygon bin.</para>
            /// <para>连续性边角 - 共享边或共享节点的图格将影响目标面图格的计算。</para>
            /// </summary>
            [Description("Contiguity edges corners")]
            [GPEnumValue("CONTIGUITY_EDGES_CORNERS")]
            _CONTIGUITY_EDGES_CORNERS,

        }

        /// <summary>
        /// <para>Number of Spatial Neighbors</para>
        /// <para>An integer specifying either the minimum or the exact number of neighbors to include in calculations for the target bin. For K nearest neighbors, each bin will have exactly this specified number of neighbors. For Fixed distance, each bin will have at least this many neighbors (the Neighborhood Distance will be temporarily extended to ensure this many neighbors if necessary). When one of the contiguity conceptualizations are selected, each bin will be assigned this minimum number of neighbors. For bins with fewer than this number of contiguous neighbors, additional neighbors will be based on feature centroid proximity.</para>
        /// <para>一个整数，指定目标箱的计算中要包括的最小或确切的邻居数。对于 K 个最近邻，每个图格将具有指定数量的邻域。对于固定距离，每个图柱将至少有这么多个邻居（如有必要，将暂时延长邻域距离以确保有这么多邻居）。选择其中一个邻接概念化时，将为每个图格分配此最小数量的相邻点。对于连续相邻点数少于此数量的图柱，其他相邻点将基于要素质心邻近性。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Spatial Neighbors")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long? _number_of_neighbors { get; set; } = null;


        /// <summary>
        /// <para>Define Global Window</para>
        /// <para><xdoc>
        ///   <para>The Anselin Local Moran's I statistic works by comparing a local statistic calculated from the neighbors for each bin to a global value. This parameter can be used to control which bins are used to calculate the global value.</para>
        ///   <bulletList>
        ///     <bullet_item>Entire cube—Each neighborhood is analyzed in comparison to the entire cube. This is the default.</bullet_item><para/>
        ///     <bullet_item>Neighborhood Time Step—Each neighborhood is analyzed in comparison to the bins contained within the specified Neighborhood Time Step.</bullet_item><para/>
        ///     <bullet_item>Individual time step—Each neighborhood is analyzed in comparison to the bins in the same time step.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>Anselin Local Moran's I 统计量的工作原理是从每个图柱的邻居计算出的局部统计量与全局值进行比较。此参数可用于控制用于计算全局值的图格。</para>
        ///   <bulletList>
        ///     <bullet_item>整个立方体 - 将分析每个邻域与整个立方体的比较。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>邻域时间步长—将分析每个邻域与指定邻域时间步长中包含的图格。</bullet_item><para/>
        ///     <bullet_item>单个时间步长—将分析每个邻域与同一时间步长中的图格进行比较。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Define Global Window")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _define_global_window_value _define_global_window { get; set; } = _define_global_window_value._ENTIRE_CUBE;

        public enum _define_global_window_value
        {
            /// <summary>
            /// <para>Entire cube</para>
            /// <para>Entire cube—Each neighborhood is analyzed in comparison to the entire cube. This is the default.</para>
            /// <para>整个立方体 - 将分析每个邻域与整个立方体的比较。这是默认设置。</para>
            /// </summary>
            [Description("Entire cube")]
            [GPEnumValue("ENTIRE_CUBE")]
            _ENTIRE_CUBE,

            /// <summary>
            /// <para>Neighborhood Time Step</para>
            /// <para>Neighborhood Time Step—Each neighborhood is analyzed in comparison to the bins contained within the specified Neighborhood Time Step.</para>
            /// <para>邻域时间步长—将分析每个邻域与指定邻域时间步长中包含的图格。</para>
            /// </summary>
            [Description("Neighborhood Time Step")]
            [GPEnumValue("NEIGHBORHOOD_TIME_STEP")]
            _NEIGHBORHOOD_TIME_STEP,

            /// <summary>
            /// <para>Individual time step</para>
            /// <para>Individual time step—Each neighborhood is analyzed in comparison to the bins in the same time step.</para>
            /// <para>单个时间步长—将分析每个邻域与同一时间步长中的图格进行比较。</para>
            /// </summary>
            [Description("Individual time step")]
            [GPEnumValue("INDIVIDUAL_TIME_STEP")]
            _INDIVIDUAL_TIME_STEP,

        }

        public LocalOutlierAnalysis SetEnv(object geographicTransformations = null, object outputCoordinateSystem = null, object parallelProcessingFactor = null, object randomGenerator = null, object scratchWorkspace = null, object workspace = null)
        {
            base.SetEnv(geographicTransformations: geographicTransformations, outputCoordinateSystem: outputCoordinateSystem, parallelProcessingFactor: parallelProcessingFactor, randomGenerator: randomGenerator, scratchWorkspace: scratchWorkspace, workspace: workspace);
            return this;
        }

    }

}